#if SAVECHANGE_TEST
using System;
using System.Windows.Forms.Design;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Collections;
using System.ComponentModel.Design;

namespace CaveArt.UIcomp
{
	public class SPOSCollectionEditor: System.ComponentModel.Design.CollectionEditor
	{

		public delegate void CollectionChangedEventHandler(object sender, object instance, object value);
		public event CollectionChangedEventHandler CollectionChanged;
		
//		private ITypeDescriptorContext _context;
//		private IWindowsFormsEditorService edSvc = null;

		public SPOSCollectionEditor()
		{
		}
		
//		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) 
//		{
//			if (context				!= null	&& 
//				context.Instance	!= null && 
//				provider			!= null) 
//			{
//				object originalValue = value;
//				
//				_context = context;
//				edSvc = (IWindowsFormsEditorService) provider.GetService( typeof(IWindowsFormsEditorService) );
//
//				if (edSvc != null) 
//				{
//					SPOSCollectionEditorForm collEditorFrm = CreateForm();
//
//					collEditorFrm.ItemAdded		+= new SPOSCollectionEditorForm.InstanceEventHandler(ItemAdded);
//					collEditorFrm.ItemRemoved	+= new SPOSCollectionEditorForm.InstanceEventHandler(ItemRemoved);
//				
//					collEditorFrm.Collection = (CollectionBase) value;
//					context.OnComponentChanging();
//
//					if ( edSvc.ShowDialog (collEditorFrm) == DialogResult.OK )
//					{
//						OnCollectionChanged( context.Instance, value );
//						context.OnComponentChanged();
//					}					
//				}
//			}
//
//			return value;
//		}
//
//		
//		public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) 
//		{
//			if (context != null && context.Instance != null) 
//			{
//				return UITypeEditorEditStyle.Modal;
//			}
//			return base.GetEditStyle(context);
//		}

		
//		private void ItemAdded(object sender, object item)
//		{
//			if(_context!=null && _context.Container!=null)
//			{
//				IComponent icomp=item as IComponent;
//				if(icomp !=null )
//				{	
//					_context.Container.Add(icomp);									
//				}
//			}
//		}
//	
//		private void ItemRemoved(object sender, object item)
//		{			
//			if(_context!=null && _context.Container!=null)
//			{
//				IComponent icomp=item as IComponent;
//				if(icomp!=null)
//				{						
//					_context.Container.Remove(icomp);
//				}
//			}
//		}

		protected virtual void OnCollectionChanged(object instance ,object value)
		{
			if(CollectionChanged !=null)
			{
				CollectionChanged(this, instance,value);
			}
		}
		
//		protected virtual SPOSCollectionEditorForm CreateForm()
//		{
//			return new SPOSCollectionEditorForm();
//		}
	}
}
#endif 